<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, user-scalable=no">
		<title>商品详情</title>
		<link rel="stylesheet" href="/static/css/style.css" />

	</head>

	<body>

		<div class="container" id="goodsDetail">
			<!--<div class="back" @click="doBack">
				<i class="icon icon-xiangzuojiantou"></i>
			</div>-->

			<div class="swiper">
				<div class="swiper-wrapper">
					{% for item in goods.detail.small_images.string %}
					<div class="swiper-slide">
						<img src="{{item}}" />
					</div>

					{% else %}
					<div class="swiper-slide">
						<img src="{{goods.pic}}" />
					</div>
					{% endfor %}

				</div>
				<div class="swiper-pagination"></div>
			</div>

			<div class="detail">
				<div class="tit">
					<h2>{{goods.title}}</h2>
					<div class="h5"><em>￥{{goods.final_price}}</em><i>￥{{goods.org_price}}</i><span class="quan">券：{{goods.coupon_amout}}元</span><span class="zhuan">分红：<em>￥{{goods.commission}}</em></span><span class="buy">已购 {{goods.sales_num}}</span></div>
					<div class="h5"><span class="zhuan">&emsp;VIP会员分红：<em>￥{{goods.vipcommission}}</em><a href="/app/wxmp/user/help#item3">如何升级VIP？</a></span></div>
					<div class="clearfix"></div>
				</div>
				

			</div>
			<div class="taoword">
				<div class="dashed">
					<h2>一键复制>打开淘宝APP</h2> 
					<p id="itemWord">复制框内整段文字【{{goods.kouling}}】，打开【淘宝APP】即可【领券】下单</p>
				</div>
				<a class="btn bg-primary" id="itemInfo" @click="clipboad">一键复制</a>
				<div class="dashed text-left">
					<h2>温馨提示</h2> 1、复制口令后可打开手淘即可自动弹出宝贝下单
					<br>2、通过口令加入购物车依然可以享受佣金，但请尽快下单
					<br>3、下单后10分钟内建议发送订单编号给机器人，即可查询战利品
					<br>4、祝亲购物愉快、省钱美滋滋、赚钱乐哈哈！

				</div>
				</div>

				

			</div>

	</body>
	<script src="/static/js/mui.min.js"></script>
	<script src="/static/js/vue.min.js"></script>
	<script src="/static/js/zepto.min.js"></script>
	<script src="/static/js/plugins/popup.js"></script>
	<script src="/static/js/plugins/swiper.js"></script>
	<script src="/static/js/plugins/clipboard.js"></script>
	<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
	<script type="text/javascript">
		
		var goodsDetail = new Vue({
			el: '#goodsDetail',
			data: {
				mallList: [{}, {}, {}, {}],
				showDetail: false,
				share: {
					title: "{{goods.title}}",
					desc: "原价：{{goods.org_price}}元，优惠券：{{goods.coupon_amout}}元\n券后价：{{goods.final_price}}元，返利：{{goods.commission}}元\n点击去淘宝购买",
					link: window.location.href,
					qrcode: "{{goods.pic}}",

				}
			},
			mounted: function() {
				this.sign();
				var swiper = new Swiper('.swiper', {
					pagination: '.swiper-pagination',
					paginationClickable: true,
					autoplay: 2000,
					loop: true,

				});

				var word = document.querySelector('#itemWord');
				document.addEventListener("selectionchange",
					function(e) {

						window.getSelection().selectAllChildren(word);
					},
					false);

			},

			methods: {
				doBack() {
					window.history.go(-1);
//					window.location.href="/wemp/goods";

				},
				sign() {

					var self = this;

					$.post('/app/wxmp/user/wxsign', {
						url: window.location.href
					}, function(res) {
						if(res.errno == 0) {

							wx.config({
								debug: false,
								appId: res.data.appid,
								timestamp: res.data.timestamp,
								nonceStr: res.data.nonceStr,
								signature: res.data.signature,
								jsApiList: ["onMenuShareTimeline", "onMenuShareAppMessage", "onMenuShareQQ", "onMenuShareWeibo", "onMenuShareQZone", "showMenuItems", "hideMenuItems"]
							});
							wx.ready(function() {
								console.log("1111111111111111")

								wx.showMenuItems({
									menuList: ["menuItem:share:appMessage", "menuItem:share:timeline", "menuItem:share:qq", "menuItem:share:QZone", "menuItem:share:weiboApp", ]
								});
								wx.hideMenuItems({
									menuList: ["menuItem:favorite", "menuItem:share:facebook", "menuItem:editTag", "menuItem:delete", "menuItem:copyUrl", "menuItem:originPage", "menuItem:readMode", "menuItem:openWithQQBrowser", "menuItem:openWithSafari", "menuItem:share:email", "menuItem:share:brand"]
								});

								wx.onMenuShareAppMessage({
									title: self.share.title, // 分享标题
									desc: self.share.desc, // 分享描述
									link: self.share.link, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
									imgUrl: self.share.qrcode, // 分享图标

									success: function() {
										// 用户确认分享后执行的回调函数
									},
									cancel: function() {
										// 用户取消分享后执行的回调函数
									}
								});

								wx.onMenuShareTimeline({
									title: self.share.title, // 分享标题
desc: self.share.desc, // 分享描述
									link: self.share.link, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
									imgUrl: self.share.qrcode, // 分享图标
									success: function() {
										// 用户确认分享后执行的回调函数
									},
									cancel: function() {
										// 用户取消分享后执行的回调函数
									}
								});

								wx.onMenuShareQQ({
									title: self.share.title, // 分享标题
									desc: self.share.desc, // 分享描述
									link: self.share.link, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
									imgUrl: self.share.qrcode, // 分享图标
									success: function() {
										// 用户确认分享后执行的回调函数
									},
									cancel: function() {
										// 用户取消分享后执行的回调函数
									}
								});

								wx.onMenuShareQZone({
									title: self.share.title, // 分享标题
									desc: self.share.desc, // 分享描述
									link: self.share.link, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
									imgUrl: self.share.qrcode, // 分享图标
									success: function() {
										// 用户确认分享后执行的回调函数
									},
									cancel: function() {
										// 用户取消分享后执行的回调函数
									}
								});

								wx.onMenuShareWeibo({
									title: self.share.title, // 分享标题
									desc: self.share.desc, // 分享描述
									link: self.share.link, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
									imgUrl: self.share.qrcode, // 分享图标
									success: function() {
										// 用户确认分享后执行的回调函数
									},
									cancel: function() {
										// 用户取消分享后执行的回调函数
									}
								});

							});

						} else {
							popup.prompt(res.errmsg);
						}
					});

				},
				collapse() {
					if(this.showDetail) {
						this.showDetail = false;
					} else {
						this.showDetail = true;
					}
				},
				clipboad() {

					var clipboard = new Clipboard('#itemInfo', {
						//动态设置复制内容
						text: function(trigger) {
							return "{{goods.kouling}}";
						}
					});

					clipboard.on('success', function(e) {
						if(e.trigger.disabled == false || e.trigger.disabled == undefined) {
							e.trigger.innerHTML = "复制成功，打开淘宝APP购买";
							e.trigger.style.backgroundColor = "#9ED29E";
							e.trigger.style.borderColor = "#9ED29E";
							// e.clearSelection();
							e.trigger.disabled = true;
							//2秒后按钮恢复原状
							setTimeout(function() {
								e.trigger.innerHTML = "一键复制";
								e.trigger.style.backgroundColor = "#ff5400";
								e.trigger.style.borderColor = "#ff5400";
								e.trigger.disabled = false;
							}, 3000);
						}
					});

					clipboard.on('error', function(e) {
						e.trigger.innerHTML = "复制失败,请手动复制";
						e.trigger.style.backgroundColor = "#8f8f8f";
						e.trigger.style.borderColor = "#8f8f8f";
					});
				}

			}

		});
	</script>

</html>